package com.taobao.dao.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import com.taobao.dao.CommonSerDao;
import com.taobao.dao.SmallerSerDao;
import com.taobao.pojo.HttpContext;

public class SmallerSerDaoImpl extends CommonSerDao implements SmallerSerDao {

    @Override
    public Object process(HttpContext context) throws Exception {
        String smallersString = context.getHtml();
        List<String> smallers = new ArrayList<String>();
        StringTokenizer st = new StringTokenizer(smallersString, ",");
        while (st.hasMoreElements()) {
            smallers.add((String) st.nextElement());
        }
        return smallers;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<String> getSmallers(String userName) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("AUserName", userName);
        return (List<String>) this.postRequest("SmallUserQuery", params);
    }
}
